/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved.
 */
package com.icinfo.cloud.provider.punish.csreason.controller;

import com.icinfo.cloud.common.core.page.PageResponse;
import com.icinfo.cloud.provider.punish.csreason.dto.CaseReasonAddParam;
import com.icinfo.cloud.provider.punish.csreason.dto.CaseReasonPageRequest;
import com.icinfo.cloud.provider.punish.csreason.dto.CaseReasonPageResponse;
import com.icinfo.cloud.provider.punish.csreason.dto.CaseReasonTree;
import com.icinfo.cloud.provider.punish.csreason.service.ICaseReasonManageService;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import com.icinfo.framework.tools.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 描述:  case_reason_manage 对应的Controller类.<br>
 *
 * @author framework generator
 * @date 2022年10月26日
 */
@RestController
@RequestMapping("/caseReason")
public class CaseReasonManageController extends BaseController {
    /**
     * 日志记录器
     */
    private static final Logger logger = LoggerFactory.getLogger(CaseReasonManageController.class);

    @Autowired
    private ICaseReasonManageService caseReasonManageService;
    // jar升级 移除本地jar
//    @Autowired
//    private ItemFeignApi itemFeignApi;

    /**
     * 描述： 保存案由信息
     *
     * @return {@link Result < String>}
     * @author: yehuafei
     * @date: 2022/10/26
     * @param: dto
     **/
    @PostMapping("/save")
    public Result<String> save(@RequestBody @Validated CaseReasonAddParam param) {
        return caseReasonManageService.save(param);
    }

    /**
     * 描述： 查询案由信息页
     *
     * @author: yehuafei
     * @date: 2022/10/26
     * @param: dto
     * @return {@link Result}
     **/
    @PostMapping("/page")
    public Result<PageResponse<CaseReasonPageResponse>> page(@RequestBody @Validated CaseReasonPageRequest request) {
        return caseReasonManageService.page(request);
    }

    /**
     * 描述： 查询案由信息树结构
     *
     * @author: yehuafei
     * @date: 2022/10/26
     * @return {@link Result}
     **/
    @GetMapping("/tree")
    public Result<List<CaseReasonTree>> tree() {
        List<CaseReasonTree> caseReasonTree = caseReasonManageService.getCaseReasonTree();
        return Result.success(caseReasonTree);
    }

    /**
     * 描述： 查询案由信息详情
     *
     * @author: yehuafei
     * @date: 2022/10/26
     * @param: id
     * @return {@link Result}
     **/
    @GetMapping("/detail")
    public Result<CaseReasonPageResponse> detail(String id) {
        if (StringUtils.isBlank(id)){
            return Result.error("id不能为空");
        }
        return Result.success(caseReasonManageService.detail(id));
    }

    /**
     * 获取项法律法规及提示文档详情
     *
     * @param itemAreaLineIdDto 区域事项id DTO类
     * @return com.icinfo.framework.common.web.Result<java.lang.String>
     * @author liuyongfei
     * @date 2022/12/02
     */
    @PostMapping(value = "/getItemLawsRegulationsFilesDetail")
    public Result<Object> getItemLawsRegulationsFilesDetail(@RequestBody Object itemAreaLineIdDto) {
        // jar升级 移除本地jar
//    public Result<ItemLawsRegulationsFilesInfoVo> getItemLawsRegulationsFilesDetail(@RequestBody ItemAreaLineIdDto itemAreaLineIdDto) {
//        return itemFeignApi.getItemLawsRegulationsFilesDetail(itemAreaLineIdDto);
        return null;
    }
}
